package com.sinoglobal.ningxia.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sinoglobal.ningxia.R;

public class ShareAdapter extends BaseAdapter {

	private Context context;
	private String[] pla = new String[] { "微信好友", "微信朋友圈", "新浪微博", "QQ", "QQ空间" };
	private int[] logo = new int[] { R.drawable.share_wechat, R.drawable.share_wechatchannel, R.drawable.share_sina, R.drawable.share_qq,
			R.drawable.share_qqzone };

	public ShareAdapter(Context context) {
		super();
		this.context = context;
	}

	@Override
	public int getCount() {
		return pla.length;
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		Holder holder;
		if (convertView == null) {
			holder = new Holder();
			convertView = LayoutInflater.from(context).inflate(R.layout.share_item, null);
			holder.image = (ImageView) convertView.findViewById(R.id.umeng_socialize_shareboard_image);
			holder.content = (TextView) convertView.findViewById(R.id.umeng_socialize_shareboard_pltform_name);
			convertView.setTag(holder);
		} else {// 有直接获得ViewHolder
			holder = (Holder) convertView.getTag();
		}
		holder.image.setBackgroundResource(logo[arg0]);
		holder.content.setText(pla[arg0]);

		return convertView;
	}

	static class Holder {
		ImageView image; // 图标
		TextView content;// 平台名
	}

}
